A basic function of a Domain Names System (DNS) server may be resolving domain names to provide a mapping relation between Internet Protocol (IP) address and domain name for a terminal. A DNS server may record a mapping relation between IP address of a local terminal or a server and domain name. Besides, if a mapping relation between target domain name requested to be resolved by a terminal and IP address does not exist in a DNS server, the DNS server may send a DNS query request packet to an authoritative DNS server to obtain the mapping relation between IP address of a non-local terminal or a server and domain name. Then the DNS server may save the obtained mapping relation to form a DNS cache.
However, the DNS cache may be vulnerable to a DNS cache poisoning attack. For example, a fake IP address may be used to replace a real IP address obtained from the authoritative DNS server, thus causing information cached in the DNS server to be fake information.
In order to prevent DNS cache poisoning, a DNS server may randomly generate a source port and a DNS request identity (ID) for a DNS query request packet, such that an attacker needs to make numerous attempts to match these parameters before possible successful poisoning. The DNS server may also prevent DNS cache poisoning by adjusting configurations thereof. For example, the DNS cache may be encrypted by Domain Name System Security Extensions (DNSSEC) technology, or a Transmission Control Protocol (TCP) function may be enabled on the DNS server.